<?php
if ( !defined('IN_SEC') ){exit();}
?>
<?php include template("admin_header");?>
                <div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

<?php include template("admin_breadcrumb");?>
						<div class="nav-search" id="nav-search">
							<form class="form-search" method="get">
<?php if(is_array($query_string)){foreach($query_string AS $k=>$v) { ?>
<?php if($k != 'totalsearch'){?>
								<input type="hidden" name="<?php echo $k; ?>" value="<?php echo htmlspecialchars($v); ?>" />
<?php }?>
<?php }}?>
								<span class="input-icon">
									<input type="text" name="totalsearch" value="<?php echo $totalsearch; ?>" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="icon-search nav-search-icon"></i>
								</span>
							</form>
						</div><!-- #nav-search -->
					</div>

					<div class="page-content">
						<div class="page-header">
							<h1><?php echo $_G['admincp']['actname']; ?><small><i class="icon-double-angle-right"></i><?php echo $_G['admincp']['optname']; ?></small></h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
                                <div class="clearfix">
                                    <div class="widget-main">
                                        <form class="form-inline" method="get">
                                        	<input name="sea_high" value="1" type="hidden" />
                                        	<input name="action" value="<?php echo $_G['admincp']['action']; ?>" type="hidden" />
                                        	<input name="operation" value="<?php echo $_G['admincp']['operation']; ?>" type="hidden" />
                                            <div class="col-xm-12">
                                                通话类型： <select class="select2" name="type"><?php echo option($types, $type, '选择'); ?></select>
                                                <div class="visible-xs visible-sm hidden-md hidden-lg space space-2"></div>
                                                通话结果： <select class="select2" name="result"><?php echo option($results, $result, '选择'); ?></select>
                                            </div>
                                            <div class="space space-2"></div>
                                            <span class="hidden-480">对方号码： </span><input type="text" value="<?php echo $contact_name; ?>" name="contact_name" class="input-small" placeholder="对方号码">
                                            <div class="visible-xs visible-sm hidden-md hidden-lg space space-2"></div>
                                            <span class="hidden-480">开始时间： </span><input type="text" value="<?php echo $begin_time ? date('Y-m-d', $begin_time) : ''; ?>" name="begin_time" class="input-small date-picker" data-date-format="yyyy-mm-dd" placeholder="联系日期">
                                            <span class="hidden-480">挂断时间： </span><input type="text" value="<?php echo $end_time ? date('Y-m-d', $end_time) : ''; ?>" name="end_time" class="input-small date-picker" data-date-format="yyyy-mm-dd" placeholder="联系日期">
                                            <div class="visible-xs visible-sm hidden-md hidden-lg space space-2"></div>
											业务员：
                                            <select class="select2" name="adminid"><?php echo option($admins, $adminid, '选择'); ?></select>

                                            <button type="submit" class="btn btn-purple btn-sm">
                                                我搜<i class="icon-search icon-on-right bigger-110"></i>
                                            </button>
                                        </form>
                                    </div>
								</div>

								<!-- PAGE CONTENT BEGINS -->
								<div class="row">
									<div class="col-xs-12">
										<div class="table-responsive">
											<table id="sample-table-1" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
														<th class="center">
															<label>
																<input type="checkbox" class="ace" />
																<span class="lbl"></span>
															</label>
														</th>
														<th>id</th>
														<th>本机号码</th>
														<th>对方号码</th>
														<th>通话类型</th>
														<th>通话结果</th>
														<th class="hidden-480">开始时间</th>
														<th class="hidden-480">挂断时间</th>
														<th class="hidden-480">总时长</th>
														<th class="hidden-480">通话时长</th>
														<th>销售人员</th>
														<th>录音</th>
													</tr>
												</thead>

												<tbody>
					<?php if(is_array($logs)){foreach($logs AS $index=>$one) { ?>
													<tr>
														<td class="center">
															<label>
																<input type="checkbox" class="checklist admin-checkbox ace" value="<?php echo $one['id']; ?>" /><span class="lbl"></span>
															</label>
														</td>

														<td><?php echo $one['id']; ?></td>
														<td><?php echo $channels[$one['channelid']]['tel']; ?></td>
														<td><?php echo $one['phone']; ?> [<?php echo $customers[$one['phone']] ? $customers[$one['phone']]['name'] : '未知'; ?>]</td>
														<td><?php echo $types[$one['type']] ? $types[$one['type']] : '未知'; ?></td>
														<td style="color:<?php echo $results_colors[$one['result']]; ?>"><?php echo $results[$one['result']] ? $results[$one['result']] : '未知'; ?></td>
														<td><?php echo date('Y-m-d H:i:s', $one['begin_time']); ?></td>
														<td><?php echo date('Y-m-d H:i:s', $one['end_time']); ?></td>

														<td><?php echo log_time($one['begin_time'], $one['end_time']); ?></td>
														<td><?php echo log_time($one['connect_time'], $one['end_time']); ?></td>

														<td><?php echo $admincp->admins[$one['adminid']] ? heivrid($admincp->admins[$one['adminid']]) : '客户池'; ?></td>
														<td>
															<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                                                            	<?php if($one['record']){?>
                                                            	<audio id="record-<?php echo $one['id']; ?>" src="http://192.168.1.195/rec/qd/<?php echo $one['record']; ?>" preload="auto"></audio>
                                                                <?php }?>
																<a dataid="<?php echo $one['id']; ?>" class="hide btn-play-record btn btn-xs btn-<?php echo $one['record'] ? 'info' : 'record'; ?>" href="javascript:void(0);">
																	<i class="icon-facetime-video bigger-120"></i>
																</a>
																<a class="btn btn-xs btn-info hide" href="?action=customer&operation=edit&detail=yes&id=<?php echo $one['id']; ?>">
																	<i class="icon-zoom-in bigger-120"></i>
																</a>
																<a class="btn btn-xs btn-info hide" href="?action=customer&operation=edit&id=<?php echo $one['id']; ?>">
																	<i class="icon-edit bigger-120"></i>
																</a>
																<a class="btn btn-xs btn-danger ajaxlink hide" href="?action=customer&operation=delete&id=<?php echo $one['id']; ?>&act=delete" ask="您确定要删除此客户？"><i class="icon-trash bigger-120"></i></a>
															</div>

															<div class="visible-xs visible-sm hidden-md hidden-lg">
																<div class="inline position-relative">
																	<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown">
																		<i class="icon-cog icon-only bigger-110"></i>
																	</button>

																	<ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
																		<li>
																			<a href="?action=customer&operation=edit&detail=yes&id=<?php echo $one['id']; ?>" class="tooltip-info" data-rel="tooltip" title="详情">
																				<span class="blue">
																					<i class="icon-zoom-in bigger-120"></i>
																				</span>
																			</a>
																		</li>

																		<li>
																			<a href="?action=customer&operation=edit&id=<?php echo $one['id']; ?>" class="tooltip-success" data-rel="tooltip" title="编辑">
																				<span class="green">
																					<i class="icon-edit bigger-120"></i>
																				</span>
																			</a>
																		</li>

																		<li>
																			<a href="javascript:void(0);" class="tooltip-error" data-rel="tooltip" title="请在PC端操作">
																				<span class="red">
																					<i class="icon-trash bigger-120"></i>
																				</span>
																			</a>
																		</li>
																	</ul>
																</div>
															</div>
														</td>
													</tr>
<?php }}?>
												</tbody>
											</table>
										</div><!-- /.table-responsive -->
											<?php echo $pages['pages']; ?>
									</div><!-- /span -->
								</div><!-- /row -->
								<div class="hr hr-18 dotted hr-double"></div>

                                <div id="modal-form" class="modal" tabindex="-1">
									<div class="modal-dialog">
										<div class="modal-content">
											
											<div id="sms-body" class="modal-body overflow-visible">
												<div class="row">
													<div class="col-xs-12 col-sm-12">
														<div class="form-group">
															<div class="col-xs-12 col-sm-12">
                                                                <input type="text" name="mobiles" class="form-field-tags" value="" placeholder="输入手机号码" />
															</div>
														</div>

														<div class="space-4"></div>

														<div class="form-group">
															<div class="col-xs-12 col-sm-12">
																<div class="widget-box col-sm-12">
																	<div class="widget-header widget-header-small header-color-blue"></div>
																	<div class="widget-body">
																			<div class="widget-main no-padding">
																				<textarea class="span12" name="content" data-provide="markdown" rows="10"></textarea>
																			</div>
																		</div>
																	</div>
															</div>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div>
		<!-- page specific plugin scripts -->
<?php include template("admin_footer");?>
		<style>
      .audiojs { width:200px; height: 22px; background: #404040;
        background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444), color-stop(0.5, #555), color-stop(0.51, #444), color-stop(1, #444));
        background-image: -moz-linear-gradient(center top, #444 0%, #555 50%, #444 51%, #444 100%);
        -webkit-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3); -moz-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3);
        -o-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3); box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3); }
      .audiojs .play-pause { width: 24px; height: 20px; padding: 0px 8px 0px 0px; }
      .audiojs p { width: 25px; height: 20px; margin: -3px 0px 0px -1px; }
      .audiojs .scrubber { background: #5a5a5a; width: 55px; height: 10px; margin: 5px; }
      .audiojs .progress { height: 10px; width: 0px; background: #ccc;
        background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ccc), color-stop(0.5, #ddd), color-stop(0.51, #ccc), color-stop(1, #ccc));
        background-image: -moz-linear-gradient(center top, #ccc 0%, #ddd 50%, #ccc 51%, #ccc 100%); }
      .audiojs .loaded { height: 10px; background: #000;
        background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #222), color-stop(0.5, #333), color-stop(0.51, #222), color-stop(1, #222));
        background-image: -moz-linear-gradient(center top, #222 0%, #333 50%, #222 51%, #222 100%); }
      .audiojs .time { float: left; height: 25px; line-height: 25px; }
      .audiojs .error-message { height: 24px;line-height: 24px; }

      .track-details { clear: both; height: 20px; width: 448px; padding: 1px 6px; background: #eee; color: #222; font-family: monospace; font-size: 11px; line-height: 20px;
        -webkit-box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.15); -moz-box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.15); }
      .track-details:before { content: '♬ '; }
      .track-details em { font-style: normal; color: #999; }
        </style>
		<link rel="stylesheet" href="/static/ace/assets/css/select2.css" />
		<link rel="stylesheet" href="/static/ace/assets/css/datepicker.css" />
		<script src="/static/derek/audiojs/audio.min.js"></script>

		<script src="/static/ace/assets/js/jquery.dataTables.min.js"></script>
		<script src="/static/ace/assets/js/jquery.dataTables.bootstrap.js"></script>
		<script src="/static/ace/assets/js/select2.min.js"></script>
		<script src="/static/ace/assets/js/bootstrap-tag.min.js"></script>
		<script src="/static/ace/assets/js/markdown/markdown.min.js"></script>
		<script src="/static/ace/assets/js/markdown/bootstrap-markdown.min.js"></script>
		<script src="/static/ace/assets/js/date-time/bootstrap-datepicker.min.js"></script>
		<!-- inline scripts related to this page -->

		<script type="text/javascript">
			var a = audiojs;
			a.events.ready(function() {
				var a1 = a.createAll();
			});
			D.Main = {
				del : function(){
					$('.delete-checks').on('click', function(){
						var lists = $('.checklist:checked');
						var datas = [];
						$.each(lists, function(i, n){
							datas.push($(this).val());
						});
						window.location.href = ('?action=customer&operation=delete&ids=' + datas.join(','));
						return false;
					});
				},
				expt : function(){
					$('.export-checks').on('click', function(){
						var lists = $('.checklist:checked');
						var datas = [];
						$.each(lists, function(i, n){
							datas.push($(this).val());
						});
						window.open('?action=customer&operation=index&export=' + datas.join(','));
						return false;
					});
				},
				checkbox : function(){
					var lists = $('.checklist:checked');
					if( lists.length > 0 ){
						$('.act-lists').removeClass('hide');
					}else{
						$('.act-lists').addClass('hide');
					}
				},
				init : function(){
					$('.date-picker').datepicker({autoclose:true}).next().on(ace.click_event, function(){
						$(this).prev().focus();
					});
					D.Main.del();
					D.Main.expt();
					$('.btn-play-record').on('click', function(){
						var dataid = $(this).attr('dataid');
					});
					$('.checklist').change(function(){
						D.Main.checkbox();
					});

					$('.send-sms').on('click', function(){
						var lists = $('.admin-checkbox:checked');
						var mobiles = [];
						$.each(lists, function(i, n){
							var box = $(this).parent().parent().parent().children('.cdata-phone');
							if ( box.text().length > 1 ){
								mobiles.push(box.text());
							}
						});
						bootbox.dialog({
							message: $('.modal-body').html(),
							title: "短信营销",
							buttons: {
								success: {
									label: "确认发送",
									className: "btn-success",
									callback: function() {
										var sms_mobiles = $('.bootbox input[name="mobiles"]').val();
										var content = $('.bootbox textarea[name="content"]').val();
										var send_valid = true;
										if( !sms_mobiles ){
											send_valid = false;
											$.gritter.add({
												title: '警告',
												text: '请输入至少一个正确的手机号码',
												class_name: 'gritter-error gritter-light'
											});
										}
										if( !content ){
											send_valid = false;
											$.gritter.add({
												title: '警告',
												text: '请输入发送内容',
												class_name: 'gritter-error gritter-light'
											});
										}
										if( send_valid ){
											bootbox.hideAll();
											D.loading.bootbox();
											var data = {
												mobiles : sms_mobiles,
												content : content
											}
											D.ajax.postdata('?action=customer&operation=sms_market', data, function(json){
												bootbox.hideAll();
												bootbox.alert(json.data);
											});
										}

										return false;
									}
								},
								cancel: {
									label: '取消'
								}
							}
						});
						var tag_input = $('.bootbox .form-field-tags');
						tag_input.val(mobiles.join(','));
						if( !( /msie\s*(8|7|6)/.test(navigator.userAgent.toLowerCase())) ) {
							tag_input.tag({
								placeholder : tag_input.attr('placeholder'),
								source: mobiles
							});
						}else {
							//display a textarea for old IE, because it doesn't support this plugin or another one I tried!
							tag_input.after('<textarea id="'+tag_input.attr('id')+'" name="'+tag_input.attr('name')+'" rows="3">'+tag_input.val()+'</textarea>').remove();
							//$('#form-field-tags').autosize({append: "\n"});
						}
					});

					$('.send-mails').on('click', function(){
						var lists = $('.admin-checkbox:checked');
						var heivrids = [];
						$.each(lists, function(i, n){
							heivrids.push($(this).val());
						});
						window.location.href = '?action=message&operation=index&sendto=' + (heivrids.join(','));
					});
				}
			}
			jQuery(function($) {
				$('.icon-mobile-phone').on('click', function(){
					bootbox.alert('正在拨号...');
					$.ajax({
						type : 'GET',
						url : 'http://192.168.1.239/htdocs/tcp.php?callback=?',
						data : {
							action : 'call',
							data : '18561674167'
						},
						dataType : 'jsonp',
						success : function(json){
							if( json.data == 'ok' ){
								bootbox.hideAll();
								bootbox.alert('已拨出');
							}
						}
					});
				});
				$('*[type="submit"]').on('click', function(){
					D.loading.bootbox();
				});
				$('#search-high').on('click', function(){
					$(this).is(':checked') ? $('.-search-').removeClass('hide').hide().slideDown() : $('.-search-').slideUp();
				});
				$(".select2").css('width','150px').select2({allowClear:true}).on('change', function(){
					$(this).closest('form').validate().element($(this));
				});
				$(".select-big").css('width','260px');

				var oTable1 = $('#sample-table-2').dataTable( {
				"aoColumns": [
			      { "bSortable": false },
			      null, null,null, null, null,
				  { "bSortable": false }
				] } );
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
					D.Main.checkbox();
				});
			
			
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			});
		</script>
<style>
.tags{ width:auto;}
</style>
</body>
</html>